home *** CD-ROM | disk | FTP | other *** search
- // Chap19_1.cpp
- class Account
- {
- public:
- //declare withdrawal pure virtual
- virtual void withdrawal(float amnt) = 0;
- };
- class Savings : public Account
- {
- public:
- virtual void withdrawal(float amnt)
- {
- }
- };
-
- void fn(Account *pAcc)
- {
- //withdraw some money
- pAcc->withdrawal(100.00F); //now it works
- };
- int main( )
- {
- Savings s; //open an account
- fn(&s);
- return 0;
- }
-